package com.example.springcloud.service.impl;

import java.util.List;

import com.example.springcloud.mapper.ScenicSpotsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.springcloud.mapper.UserScenicFavoriteMapper;
import com.example.springcloud.domain.UserScenicFavorite;
import com.example.springcloud.service.IUserScenicFavoriteService;

/**
 * 用户景点收藏Service业务层处理
 * 
 * @author helian
 * @date 2025-03-09
 */
@Service
public class UserScenicFavoriteServiceImpl implements IUserScenicFavoriteService 
{
    @Autowired
    private UserScenicFavoriteMapper userScenicFavoriteMapper;

    @Autowired
    private ScenicSpotsMapper scenicSpotsMapper;

    /**
     * 查询用户景点收藏
     * 
     * @param id 用户景点收藏主键
     * @return 用户景点收藏
     */
    @Override
    public UserScenicFavorite selectUserScenicFavoriteById(Long id)
    {
        UserScenicFavorite userScenicFavorite = userScenicFavoriteMapper.selectUserScenicFavoriteById(id);
        userScenicFavorite.setScenicSpots(scenicSpotsMapper.selectScenicSpotsByScenicId(userScenicFavorite.getScenicId()));
        return userScenicFavorite;
    }

    /**
     * 查询用户景点收藏列表
     * 
     * @param userScenicFavorite 用户景点收藏
     * @return 用户景点收藏
     */
    @Override
    public List<UserScenicFavorite> selectUserScenicFavoriteList(UserScenicFavorite userScenicFavorite)
    {
        List<UserScenicFavorite> userScenicFavoriteList = userScenicFavoriteMapper.selectUserScenicFavoriteList(userScenicFavorite);
        for (UserScenicFavorite item : userScenicFavoriteList) {
            item.setScenicSpots(scenicSpotsMapper.selectScenicSpotsByScenicId(item.getScenicId()));
        }
        return userScenicFavoriteList;
    }

    /**
     * 新增用户景点收藏
     * 
     * @param userScenicFavorite 用户景点收藏
     * @return 结果
     */
    @Override
    public int insertUserScenicFavorite(UserScenicFavorite userScenicFavorite)
    {
        return userScenicFavoriteMapper.insertUserScenicFavorite(userScenicFavorite);
    }

    /**
     * 修改用户景点收藏
     * 
     * @param userScenicFavorite 用户景点收藏
     * @return 结果
     */
    @Override
    public int updateUserScenicFavorite(UserScenicFavorite userScenicFavorite)
    {
        return userScenicFavoriteMapper.updateUserScenicFavorite(userScenicFavorite);
    }

    /**
     * 批量删除用户景点收藏
     * 
     * @param ids 需要删除的用户景点收藏主键
     * @return 结果
     */
    @Override
    public int deleteUserScenicFavoriteByIds(Long[] ids)
    {
        return userScenicFavoriteMapper.deleteUserScenicFavoriteByIds(ids);
    }

    /**
     * 删除用户景点收藏信息
     * 
     * @param id 用户景点收藏主键
     * @return 结果
     */
    @Override
    public int deleteUserScenicFavoriteById(Long id)
    {
        return userScenicFavoriteMapper.deleteUserScenicFavoriteById(id);
    }

    @Override
    public int deleteUserScenicFavoriteByUserIdAndScenicId(Long userId, Long scenicId) {
        return userScenicFavoriteMapper.deleteUserScenicFavoriteByUserIdAndScenicId(userId, scenicId);
    }
}
